<?php
drupal_add_css('css/ui-lightness/jquery-ui-1.8.16.custom.css');
drupal_add_js('js/jquery-ui-1.8.16.custom.min.js');
drupal_add_js('js/jquery.validate.min.js');
drupal_add_js('js/script.gallery.js');
?>
<div id="error">
    <ul></ul>
</div>
<form name="<?php echo empty($data['gallery']) ? 'add_gallery' : 'edit_gallery' ?>" id="<?php echo empty($data['gallery']) ? 'add_gallery' : 'edit_gallery' ?>" action="" method="POST" enctype="multipart/form-data">
    <div>
        <div class="node-form">
            <div class="standard">                
                <div class="form-item">
                    <label for="title">Tiêu đề: <span title="Trường bắt buộc." class="form-required">*</span></label>
                    <input type="text" value="<?php if(!empty($data['gallery'])) echo $data['gallery']->title ?>" size="60" id="title" name="title" maxlength="100">
                </div>

                <div class="form-item">
                    <label for="page">Hiển thị tại: <span title="Trường bắt buộc." class="form-required">*</span></label>                    
                    <select id="page" name="page">
                        <option value="">-- Chọn trang hiển thị --</option>
                        <?php
                            $positions = unserialize(GALLERY_PAGES);
                            if (!empty($positions)) {
                                foreach ($positions as $key => $title) {
                                    echo '<option value="' . $key . '" ' . ($data['gallery']->page == $key ? 'selected="selected"' : '') . '>' . $title . '</option>';
                                }
                            }
                        ?>
                    </select>
                </div>
                <div class="form-item">
                    <label for="position">Vị trí:</label>
                    <input type="text" value="<?php if(!empty($data['gallery'])) echo $data['gallery']->position; else echo 1; ?>" size="5" id="position" name="position" maxlength="3">
                </div>
                <div class="form-item">
                    <label for="file">Banner: <?php if(empty($data['gallery'])) echo '<span title="Trường bắt buộc." class="form-required">*</span>'; ?></label>
                    <input type="file" size="30" id="file" name="file" />
                    <?php 
                    	if(!empty($data['gallery'])) {                    		
                    		if ($data['gallery']->type == GALLERY_TYPE_IMAGE) {
                    			echo '<br /><img style="max-width: 250px;" src="' . GALLERY_PATH . '/' . $data['gallery']->file . '" alt="' . $data['gallery']->title . '" title="' . $data['gallery']->title . '" />';
                    		} else {
                    			echo '<br /><embed width="250" height="90" pluginspage="http://www.macromedia.com/go/getflashplayer" menu="false" scalemode="noScale" quality="high" allowscriptaccess="always" wmode="transparent" flashvars="" type="application/x-shockwave-flash" src="' . GALLERY_PATH . '/' . $data['gallery']->file . '">';
                    		}                    		
                    	}
                    ?>
                </div>

                <div class="form-item">
                    <label for="link">Link website:</label>
                    <input type="text" value="<?php if(!empty($data['gallery'])) echo $data['gallery']->link ?>" size="60" id="link" name="link" maxlength="255">
                </div>

                <div class="form-item">
                    <label for="start_end">Thời gian:</label>
                    Bắt đầu: <input value="<?php if(!empty($data['gallery'])) echo date('m/d/Y', $data['gallery']->start) ?>" type="text" size="15" id="from" name="from" readonly="true" />
                    Kết thúc: <input value="<?php if(!empty($data['gallery'])) echo date('m/d/Y', $data['gallery']->end) ?>" type="text" size="15" id="to" name="to" readonly="true" />
                </div>

                <div class="form-item">
                    <label for="status">Trạng thái:</label>
                    <select name="status" id="status">
                        <option value="<?php echo GALLERY_STATUS_SHOW ?>" selected="selected">Hiển thị</option>
                        <option <?php if(!empty($data['gallery']) && $data['gallery']->status == GALLERY_STATUS_HIDE) echo 'selected="selected"' ?> value="<?php echo GALLERY_STATUS_HIDE ?>">Không hiển thị</option>
                    </select>
                </div>
                
                <!-- hidden input uid, shop_id de phase 2 phat trien sau -->
                <input type="hidden" name="uid" value="1" />
                <input type="hidden" name="sid" value="1" />

                <input type="submit" value="Lưu" />
                <input type="reset" rel="<?php echo empty($data['gallery']) ? 'add_gallery' : 'edit_gallery' ?>" value="Nhập lại" />                
				<?php echo l( 'Quay lại', 'back-end/gallery' ) ?>
            </div>
        </div>
    </div>
</form>